package sys.cloud.escape;

/**
 * Created by shiyusen on 2017/3/23.
 */
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpServletResponseWrapper;
import java.io.ByteArrayOutputStream;
import java.io.PrintWriter;
public class MyResponseWrapper extends HttpServletResponseWrapper {
    private ByteArrayOutputStream baos;
    private ByteArrayServletOutputStream basos;
    private PrintWriter pw;
    public MyResponseWrapper(HttpServletResponse response) {
        super(response);
        baos = new ByteArrayOutputStream();
        basos = new ByteArrayServletOutputStream(baos);

        pw = new PrintWriter(baos);
    }
    public PrintWriter getWriter(){ return pw;}

    public ServletOutputStream getOutputStream(){ return basos; }

    public byte[] toByteArray(){ return baos.toByteArray(); }
}